import IndexModel from '@/models/newsIndex';
import GalleryModel from '@/models/gallery';
import GalleryService from '@/services/galleryService';
import { action, computed, observable } from 'mobx';

export default class Gallerystore {
  //图片地址
  @observable
  imageURL: string = 'https://image.xiaokesi.com/';
  @observable
  pageSize?: number = 5;
  @observable
  pageNumber?: number = 1;
  @observable
  title?: string;
  @observable
  tag?: number;
  @observable
  tagName?: string;
  @observable
  status: number | undefined;
  @observable
  statusName: string | undefined;
  @observable
  count: number | undefined;
  @observable
  galleryList?: Array<GalleryModel>;
  @observable
  galleryListLoading: boolean = false;
  @observable
  galleryInfo?: GalleryModel;
  @observable
  galleryInfoLoading: boolean = false;


  @action
  async listGallery() {
    this.galleryListLoading = true;
    let option = {
      pageNumber: this.pageNumber,
      pageSize: this.pageSize,
      title: this.title,
      tag: this.tag,
      tagName: this.tagName,
      status: this.status,
      statusName: this.statusName,
    }
    this.galleryList = (await GalleryService.list(option)).dataList;
    this.galleryListLoading = false;
    console.log(this.galleryList);

  }
  @action
  async infoGallery(id: any) {
    this.galleryInfoLoading = true;
    this.galleryInfo = (await GalleryService.info(id)).dataInfo;
    this.galleryInfoLoading = false;
  }
}
export const galleryStore = new Gallerystore();
